﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace CMS6Tools.TFSTasks
{
    internal static class TaskManager
    {
        static readonly List<Type> TaskTypes = new List<Type>();
        static TaskManager()
        {
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            TaskTypes = assemblies.SelectMany(a => a.GetTypes().Where(b => typeof(ITask).IsAssignableFrom(b))).ToList();
        }

        internal static Type GetTaskType(string typeName)
        {
            return TaskTypes.FirstOrDefault(a => a.Name.Equals(typeName));
        }
    }
}
